//
//  JXPDetialPicViewController.m
//  模拟-百思不得姐
//
//  Created by ColinJ on 16/8/10.
//  Copyright © 2016年 colin. All rights reserved.
//

#import "JXPDetialPicViewController.h"

@interface JXPDetialPicViewController ()

@property (nonatomic,strong)UIScrollView *myScrollView;
//存放图片的imgeView
@property(nonatomic,strong)UIImageView *imgView;
@end

@implementation JXPDetialPicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    XMGLog(@"%@\n%@\n%@",_model.image0,_model.image1,_model.image2);

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(10, 20, 30, 30);
    [btn setImage:[UIImage imageNamed:@"JXPBackBtn"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(tapAction) forControlEvents:UIControlEventTouchUpInside];
    float imgwidth = [_model.width floatValue];
    float imgheight =[_model.height floatValue];
    float bili = (self.view.width - 20) /imgwidth;
    float phoneH = bili*imgheight;

    self.myScrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
    self.automaticallyAdjustsScrollViewInsets = NO;
    _myScrollView.contentSize = CGSizeMake(self.view.width, phoneH);
    _myScrollView.bounces = NO;
    _myScrollView.backgroundColor = [UIColor blackColor];
    
    self.imgView = [[UIImageView alloc]init];
        _imgView.frame = CGRectMake(10, 0, self.view.width-20, phoneH);
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_model.image0] placeholderImage:[UIImage imageNamed:@"AppIcon40x40@3x"]];
    _imgView.userInteractionEnabled = YES;
    
    if (_imgView.frame.size.height < self.view.height ) {
        _imgView.center = self.view.center;
    }
    
    
    [self.myScrollView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)]];
    self.myScrollView.userInteractionEnabled = YES;
    
    [self.myScrollView addSubview:_imgView];
    [self.view addSubview:_myScrollView];
    [self.view addSubview:btn];
//    self.modalPresentationCapturesStatusBarAppearance = NO;
//    [self prefersStatusBarHidden];
    
}

- (BOOL)prefersStatusBarHidden{
    return YES;
}

- (void)tapAction{
    [self dismissViewControllerAnimated:NO completion:^{
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
